package cn.terminus.data.customer.contractselldefylatedeliveryinfo.impl;

import cn.terminus.common.customer.bean.contractselldefylatedeliveryinfo.dto.*;
import cn.terminus.data.customer.contractselldefylatedeliveryinfo.dao.ContractSellDefyLateDeliveryInfoDao;
import cn.terminus.data.customer.contractselldefylatedeliveryinfo.mapper.ContractSellDefyLateDeliveryInfoMapper;
import cn.terminus.result.common.page.TerminusPageAble;
import cn.terminus.result.common.page.TerminusPageInfo;
import cn.terminus.result.common.util.BeanCopyUtils;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * 合同售卖交付违约(ContractSellDefyLateDeliveryInfo)表服务实现类
 *
 * @author makejava
 * @since 2021-07-21 11:17:56
 */
@Repository
public class ContractSellDefyLateDeliveryInfoDaoImpl implements ContractSellDefyLateDeliveryInfoDao {
    @Resource
    private ContractSellDefyLateDeliveryInfoMapper contractSellDefyLateDeliveryInfoMapper;

    @Override
    public Integer add(ContractSellDefyLateDeliveryInfoNewDto dto) {
        return contractSellDefyLateDeliveryInfoMapper.add(dto);
    }

    @Override
    public Integer update(ContractSellDefyLateDeliveryInfoEditDto dto) {
        return contractSellDefyLateDeliveryInfoMapper.update(dto);
    }

    @Override
    public List<ContractSellDefyLateDeliveryInfoResultDto> gets(ContractSellDefyLateDeliveryInfoGetsDto dto) {
        return contractSellDefyLateDeliveryInfoMapper.gets(dto);
    }

    @Override
    public List<ContractSellDefyLateDeliveryInfoResultDto> query(ContractSellDefyLateDeliveryInfoQueryDto dto) {
        return contractSellDefyLateDeliveryInfoMapper.query(dto);
    }

    @Override
    public Integer delete(ContractSellDefyLateDeliveryInfoDeleteDto dto) {
        return contractSellDefyLateDeliveryInfoMapper.delete(dto);
    }

    @Override
    public TerminusPageAble<ContractSellDefyLateDeliveryInfoResultDto> page(ContractSellDefyLateDeliveryInfoQueryDto dto, TerminusPageInfo page) {
        PageHelper.startPage(page.getCurrentPage(), page.getPageSize());
        Page<ContractSellDefyLateDeliveryInfoResultDto> result = (Page<ContractSellDefyLateDeliveryInfoResultDto>) contractSellDefyLateDeliveryInfoMapper.query(dto);
        return new TerminusPageAble<>(BeanCopyUtils.copy(result.getResult(), ContractSellDefyLateDeliveryInfoResultDto.class), page, result.getTotal());
    }

    @Override
    public Integer deleteWithContractId(Long id) {

        return contractSellDefyLateDeliveryInfoMapper.deleteWithContractId(id);
    }
}
